import { defineStore } from 'pinia'
import type { AppState } from '../type'

const useAppStore = defineStore({
  id: 'app',
  state: (): AppState => ({
    socketData: null,
    socketStatus: null,
    socketConnectEnd: false,
    tableSearchFormInfo: {},
  }),
  actions: {
    setSocketData(data: any) {
      this.socketData = data
    },
    setSocketStatus(status: any) {
      this.socketStatus = status
    },
    setSocketAttempts(connect: boolean) {
      this.socketConnectEnd = connect
    },
    saveSearchFormInfo(data: any) {
      this.tableSearchFormInfo = data
    },
    async RESET_STATE() {
      this.$reset()
    },
  },
})

export default useAppStore
